#ifndef __FIFO_H__
#define __FIFO_H__

#include <stdbool.h>
#include <stdint.h>

/* CAN message struct */
typedef struct
{
    uint32_t std_id; /*!< standard format frame identifier */
#if 0
    uint32_t            efid;                 /*!< extended format frame identifier */
    uint32_t            ff;                   /*!< format of frame, standard or extended format */
    uint32_t            ft;                   /*!< type of frame, data or remote */
#endif
    uint32_t dlc;    /*!< data length */
    union
    {
        uint32_t word[2];
        uint8_t  byte[8];
    } data; /*!< transmit data */

} CAN_Frame_t;

typedef struct
{
    uint32_t     front;         /* Front of the queue */
    uint32_t     rear;          /* Rear of the queue */
    uint32_t     count;         /* Queue count */
    CAN_Frame_t *can_frame_buf; /* Can frame buffer */
    uint32_t     depth;         /* Depth of the queue */
} CAN_Queue_t;

void     FIFO_QueueInit(CAN_Queue_t *queue, CAN_Frame_t *can_buf, uint32_t depth);
bool     FIFO_QueueIsEmpty(CAN_Queue_t *queue);
bool     FIFO_QueueIsFull(CAN_Queue_t *queue);
bool     FIFO_QueuePush(CAN_Queue_t *queue, CAN_Frame_t can_frame);
bool     FIFO_QueuePop(CAN_Queue_t *queue, CAN_Frame_t *can_frame);
uint16_t FIFO_QueueGetFreeDepth(CAN_Queue_t *queue);

#endif
